---
title: "Grid Template Columns"
# description: "Utilities for specifying the columns in a grid layout."
description: "用于在网格布局中指定列的功能类。"
---

import plugin from 'tailwindcss/lib/plugins/gridTemplateColumns'
import { Variants } from '@/components/Variants'
import { Disabling } from '@/components/Disabling'

export const classes = { plugin }

<!-- ## Usage -->
## 使用方法

<!-- Use the `grid-cols-{n}` utilities to create grids with _n_ equally sized columns. -->
使用 `grid-cols-{n}` 功能类来创建有_n_个同等大小的列的网格。

```html fuchsia
<template preview class="bg-white p-8">
  <div class="grid grid-cols-3 gap-4">
    <div class="bg-fuchsia-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">1</div>
    <div class="bg-fuchsia-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">2</div>
    <div class="bg-fuchsia-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">3</div>
    <div class="bg-fuchsia-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">4</div>
    <div class="bg-fuchsia-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">5</div>
    <div class="bg-fuchsia-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">6</div>
    <div class="bg-fuchsia-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">7</div>
    <div class="bg-fuchsia-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">8</div>
    <div class="bg-fuchsia-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">9</div>
  </div>
</template>

<div class="grid **grid-cols-3** gap-4">
  <div>1</div>
  <!-- ... -->
  <div>9</div>
</div>
```

<!-- ## Responsive -->
## 响应式

<!-- To control the columns of a grid at a specific breakpoint, add a `{screen}:` prefix to any existing grid-template-columns utility. For example, use `md:grid-cols-6` to apply the `grid-cols-6` utility at only medium screen sizes and above. -->
要在特定的断点处控制网格的列，可以在任何现有的 grid-template-columns 功能类前添加 `{screen}:` 前缀。例如，使用 `md:grid-cols-6` 来仅在中等尺寸及以上的屏幕上应用 `grid-cols-6` 功能类。

```html
<div class="grid grid-cols-1 **md:grid-cols-6**">
  <!-- ... -->
</div>
```

<!-- For more information about Tailwind's responsive design features, check out the [Responsive Design](/docs/responsive-design) documentation. -->
关于 Tailwind 的响应式设计功能的更多信息，请查看 [响应式设计](/docs/responsive-design) 文档。

<!-- ## Customizing -->
## 定制

<!-- By default Tailwind includes grid-template-column utilities for creating basic grids with up to 12 equal width columns. You change, add, or remove these by customizing the `gridTemplateColumns` section of your Tailwind theme config. -->
默认情况下，Tailwind 包括 grid-template-column 功能，用于创建基本的网格，最多有12个等宽的列。您可以通过定制您的 Tailwind 主题配置的 `gridTemplateColumns` 部分来改变、添加或删除它们。

<!-- You have direct access to the `grid-template-columns` CSS property here so you can make your custom column values as generic or as complicated and site-specific as you like. -->
在这里您可以直接访问 `grid-template-columns` CSS属性，所以您可以让您的自定义列值变得通用或复杂，因网站而异。

```diff-js
  // tailwind.config.js
  module.exports = {
    theme: {
      extend: {
        gridTemplateColumns: {
          // Simple 16 column grid
+         '16': 'repeat(16, minmax(0, 1fr))',

          // Complex site-specific column configuration
+         'footer': '200px minmax(900px, 1fr) 100px',
        }
      }
    }
  }
```

<!-- Learn more about customizing the default theme in the [theme customization documentation](/docs/theme#customizing-the-default-theme). -->
在 [主题自定义文档](/docs/theme#customizing-the-default-theme) 中了解更多关于自定义默认主题的信息。

### 变体

<Variants plugin="gridTemplateColumns" name="grid-template-columns" />

### 禁用

<Disabling plugin="gridTemplateColumns" name="grid-template-columns" />
